// let baseUrl = 'http://192.168.0.67:8088/etc'

// if (process.env.NODE_ENV === 'development') {
// 	baseUrl = '/dev-api'
// } else {
import { merge } from 'loadsh';
import { TOKEN_KEY } from '@/enums/cacheEnum.js'
import { showNotify } from 'vant';
// import { useUserStoreWithOut } from '@/store/modules/user.js'

// const userStore = useUserStoreWithOut();

export const baseUrl = 'http://183.67.28.94:8889' //'/api' //'https://yzx.gs12122.com:8432'
// 'http://183.230.194.140:8889'
// '/api' ;
// : 'http://192.168.0.67:8088/etc';


export const apis = {
	details: baseUrl + '/etc/scenicSpots/detail', ///etc/scenicSpots/detail/{id}
}

// 参数同uni.request
export function request(options){
	// alert(uni.getStorageSync(TOKEN_KEY));
	const defaultOpt= {
		header: {
			// uni.getStorageSync(TOKEN_KEY)
			Authorization: uni.getStorageSync(TOKEN_KEY),
			version: uni.getStorageSync('API_VERSION')//'android_1.1.12'
			 // ||'eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiJldGMiLCJpYXQiOjE2OTIwODU0NjAsInVzZXJJZCI6IjE5MjA5NTEwNzcwMzUwODk5MiIsImV4cCI6MTY5NDY3NzQ2MH0.wwr4c0RznJPjnxlRg64ipeQeW2q98GYBXBnSRhKu7tqzoKCRTxpOcdpDpHtCeEJT-tTVf7sF8aP9MKbjRNk8Ig'
		},
	}
	const _opt = merge(defaultOpt,options)
	return new Promise((resolve,reject)=>{
		uni.request({
			..._opt,
			success(res) {
				resolve(res),
				_opt.success && _opt.success(res)
				if(res.data.code && res.data.code != 200) {
					showNotify({message: res.data.msg || res.data.message})
				}
			},
			fail(err) {
				showNotify({message: err.errMsg})
				reject(err)
				_opt.fail && _opt.fail(err)
			}
		})
	})
}

